/*
 * @Description: 模拟登陆工具类
 * @Author: tao.xie
 * @Date: 2019-04-02 11:27:04
 * @Last Modified by: shuaishuai.wang
 * @Last Modified time: 2019-09-02 15:46:23
 */
import md5 from 'js-md5'
import { ajaxAsync, UserBeanUtils } from 'vue-xiaobu-utils'

const TestInVue = true

const PHONE_NO = '18658153079'
const PWD = 'hbw666'

export default async function testLogin() {
  // localStorage.setItem('XIAOBUSESSION', 'K7YXVILOBHENA7CREVWFAFZD7RTFHN0F')
  if (!window.prodInApp && TestInVue) {
    let pwd = md5(PWD)
    let json = {
      USERNAME: PHONE_NO,
      PASSWORD_MD5: pwd,
      MOBILE_MODEL: 1,
      CID: 'db92091a0a7057df248fe909d754e4e0',
      MOBILE_VERSION: 'HWPRA-H;PRA-AL00;7.0;NNet:7;P:2',
      APP_VERSION: '1.0.0'
    }
    try {
      let rs = await ajaxAsync('/user/login', json)
      localStorage.setItem('XIAOBUSESSION', rs.SESSION_ID)
      rs.PHONE = PHONE_NO
      rs.IS_LOGIN = 1
      UserBeanUtils.setUserInfo(rs)
    } catch (err) { }
  }
}
